#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int common_divisor = 0;
	int a, b;
	scanf("%d %d", &a, &b);
	int min = a;
	if (a > b)
	{
		min = b;
	}
	for (int z = 1; z <= min; z++)
	{
		if (a % z == 0 && b % z == 0)
			common_divisor = z;
	}
	printf("%d", common_divisor);
}